/**
 * @author: 小佘佘🦀
 * @description: 重命名
 * @param {string} email
 * @param {string} newName
 * 
 * */

import { isCodeMessage } from "../config"

export const rename = async (email: string, newName: string) => {

    const params = new URLSearchParams()
    params.append("email", email)
    params.append("newName", newName)


    const response = await fetch(`/api-backend/api/user/rename`, {
        method: "post",
        mode: "no-cors",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
        body: params.toString(),       
        redirect: "manual" 
    })
    

    return isCodeMessage(response)
}